home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource1 / bootsec / bootsec.c < prev    next >
C/C++ Source or Header  |  1993-07-08  |  25KB  |  662 lines

  1. //****************************************************************************
  2. // File:        BOOTSEC.C        
  3. //          
  4. //
  5. // Purpose:     The main module.  Brings up a private dialog, that prompts 
  6. //              the user for a drive letter.  When the user chooses "Get
  7. //              Info", BOOTSEC determines what kind of drive it is, and then if 
  8. //              appropriate, reads the boot sector of the drive, and displays
  9. //              all the information from the bootsector in the dialog.
  10. //
  11. // Functions:
  12. //            WinMain()       -  initializes app and processes message loop 
  13. //            ActualDlgProc         -  the actual Dialog Procedure
  14. //            AboutDlgProc    -  Dialog procedure for the About box
  15. //            ClassDlgProc    -  the Window Proc for the Private Dialog
  16. //            NewEditProc     -  the subclassed Edit window procedure 
  17. //            ReadBootSector  -  read the boot sector via INT 25
  18. //            ShowDriveInfo   -  display the boot sector structure
  19. //            GetPictRect     -  get a rect to display a drive icon
  20. //            IsCDRomDrive    -  is it a CD-ROM drive?
  21. //            IsNetDrive      -  is it a network drive?
  22. //            SetAllLabels    -  show a given string in all the labels 
  23. //            MyGetDriveType  -  return the type of drive
  24. //
  25. // Development Team:                   
  26. //
  27. //                  Joe Long, June 1993
  28. //
  29. //
  30. // Written by Microsoft Product Support Services, Windows Developer Support
  31. // Copyright (c) 1992 Microsoft Corporation. All rights reserved.
  32. //****************************************************************************
  33.  
  34.  
  35. #include "windows.h"                           
  36. #include "bootsec.h"
  37. #include "memory.h"
  38. #include "resource.h"
  39. #define CBSECTORSIZE 512
  40.  
  41. // global vars
  42. int iDriveType;          // what kind of drive is selected
  43. HINSTANCE hInst;         // the instance handle
  44. FARPROC lpfnOldEditProc; // the original edit procedure                     
  45. char szErrorBuf[64];     // a buffer to load error strings
  46.  
  47. // exported function
  48. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
  49. BOOL FAR PASCAL __export ActualDlgProc (HWND hDlg, UINT message,  WPARAM wParam, LPARAM lParam);
  50. BOOL FAR PASCAL __export AboutDlgProc (HWND hDlg, UINT message,  WPARAM wParam, LPARAM lParam);
  51. long FAR PASCAL __export ClassDlgProc(HWND hDlg, UINT message, WPARAM wParam , LPARAM lParam);
  52. long FAR PASCAL __export NewEditProc(HWND hEdit, UINT message, WPARAM wParam , LPARAM lParam);
  53.  
  54. //helper functions
  55. BOOL ReadBootSector(int iDrive, PSTR pBuf);
  56. void ShowDriveInfo(HWND hDlg, BOOTSECTOR *bs);
  57. void GetPictRect(HWND hWnd, LPRECT lpRect);   
  58. BOOL IsCDRomDrive(int iDrive);    
  59. WORD IsNetDrive(int iDrive);            
  60. void SetAllLabels(HWND hDlg, LPSTR szText);              
  61. int MyGetDriveType(BOOTSECTOR *bs);
  62.  
  63.  
  64. /****************************************************************************
  65.  
  66.     FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
  67.  
  68.     PURPOSE: calls initialization function, processes message loop
  69.  
  70. ****************************************************************************/
  71.  
  72. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  73. {
  74.     MSG msg;
  75.     WNDCLASS wc;
  76.     HWND hwnd;  
  77.  
  78.     DLGPROC dlgProc;
  79.     hInst = hInstance;  
  80.  
  81.     if (!hPrevInstance)
  82.     {
  83.         memset(&wc,NULL, sizeof(WNDCLASS));
  84.         wc.lpfnWndProc = ClassDlgProc;   
  85.         wc.cbWndExtra = DLGWINDOWEXTRA;
  86.         wc.hInstance = hInstance;
  87.         wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MAIN));
  88.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  89.         wc.hbrBackground = COLOR_WINDOW + 1;
  90.         wc.lpszClassName = "BootSectorClass";    
  91.         RegisterClass(&wc);    
  92.     }               
  93.     dlgProc = (DLGPROC)MakeProcInstance(ActualDlgProc, hInst); 
  94.     hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAINDIALOG), 0, dlgProc);        
  95.     ShowWindow(hwnd,nCmdShow);
  96.     while (GetMessage(&msg,NULL,0,0))
  97.     {
  98. // if we want to be able to use the TAB key
  99. // to move between controls, the ENTER
  100. // key to execute the default button, 
  101. // the ESCAPE key to dismiss the dialog, 
  102. // or any other dialog - type functionality,
  103. // we must call IsDialogMessage() 
  104.         if (!IsDialogMessage(hwnd, &msg))
  105.         {
  106.             TranslateMessage(&msg);
  107.             DispatchMessage(&msg);    
  108.         }
  109.     
  110.     }                                                                     
  111.     FreeProcInstance((FARPROC)dlgProc);
  112.     return msg.wParam;                            
  113.     
  114.     
  115. }   
  116.  
  117.  
  118. /****************************************************************************
  119.  
  120.     ClassDlgProc(HWND hDlg, UINT message, WPARAM wParam , LPARAM lParam)
  121.  
  122.     PURPOSE: 
  123.      this function gets placed between the dialog and the DefDlgProc because
  124.       
  125.         1. its a private dialog 
  126.      and
  127.         2. we specified a DLGPROC for the  third parameter 
  128.            of the CreateDialog() call.
  129.            
  130.     we could handle all of the messages here (except for the WM_INITDIALOG 
  131.     message which is not sent to non-dialogs, or we can pass the messages 
  132.     off to DefDlgProc(), which will then call our dialog procedure 
  133.     ActualDlgProc(), given below    
  134.  
  135. ****************************************************************************/
  136. long FAR PASCAL __export ClassDlgProc(HWND hDlg, UINT message, WPARAM wParam , LPARAM lParam)
  137. {
  138.   
  139.     return DefDlgProc(hDlg, message, wParam, lParam);
  140.     
  141. }      
  142.  
  143.  
  144. /****************************************************************************
  145.  
  146.     ActualDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  147.  
  148.     PURPOSE: 
  149.     The procedure for the application that does most of the work.
  150.     
  151.     This is the function that we passed in as the last parameter to the
  152.     CreateDialog() call.  We do this so that we can get the WM_INITDIALOG
  153.     message, which is not passed to the WndProc of a Private Dialog.
  154.     
  155.     We subclass the edit control so that we can restrict input to capital
  156.     letters, the backspace key, and the TAB key. 
  157.  
  158. ****************************************************************************/
  159.        
  160. BOOL FAR PASCAL __export ActualDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  161. {
  162.     static HDC hMemDC;
  163.     static HBITMAP hBitmap, hbmOld;
  164.   
  165.     switch (message)
  166.     {        
  167.         case WM_INITDIALOG:
  168.         {
  169.             HDC hdc;            
  170.             HWND hwndEdit; 
  171.             HMENU hSysMenu;
  172.             hSysMenu = GetSystemMenu(hDlg, FALSE);                            
  173.             // disable the "maximize" option in the system menu
  174.             EnableMenuItem(hSysMenu, 4, MF_GRAYED|MF_DISABLED|MF_BYPOSITION); 
  175.             // disable the "size" option of the system menu                   
  176.             EnableMenuItem(hSysMenu, 2, MF_GRAYED|MF_DISABLED|MF_BYPOSITION); 
  177.                    
  178.             // subclass the edit control so that we
  179.             // can restrict input to letter only
  180.             hwndEdit = GetDlgItem(hDlg, IDC_DRIVE);
  181.             if (hwndEdit)
  182.                 lpfnOldEditProc = (FARPROC)SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG)NewEditProc);    
  183.                 
  184.             // limit the text of the edit control to 1 character
  185.             SendMessage(hwndEdit, EM_LIMITTEXT, 1, 0L);
  186.             
  187.             // put a reasonable default into the edit control
  188.             SetWindowText(hwndEdit, "C");
  189.             
  190.  
  191.             hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_DRIVES));
  192.             hdc = GetDC(NULL);
  193.             hMemDC = CreateCompatibleDC(hdc);
  194.             ReleaseDC(NULL, hdc);
  195.             hbmOld = SelectObject(hMemDC, hBitmap);        
  196.             iDriveType = BM_NONE;
  197.             return FALSE;   // didn't set the focus
  198.             
  199.         }
  200.         break;                                     
  201.         case WM_PAINT:  
  202.         {
  203.             PAINTSTRUCT ps;
  204.             RECT rect;            
  205.             BeginPaint(hDlg, &ps);
  206.             GetPictRect(hDlg, &rect);            
  207.             BitBlt(ps.hdc,rect.left, rect.top, 
  208.                           BM_WIDTH, BM_HEIGHT,
  209.                           hMemDC, 
  210.                           iDriveType * BM_WIDTH,
  211.                           0,
  212.                           SRCCOPY);            
  213.             EndPaint(hDlg, &ps);
  214.          }         
  215.          break;                
  216.         case WM_COMMAND:
  217.             switch (wParam)
  218.             {
  219.                 case ID_ABOUT:
  220.                 {
  221.                     DLGPROC dlgprc;
  222.                     dlgprc = (DLGPROC) MakeProcInstance(AboutDlgProc, hInst);
  223.                     DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hDlg, dlgprc);
  224.                     FreeProcInstance((FARPROC) dlgprc);                 
  225.                 }
  226.                 break;                
  227.                 case ID_GET:             
  228.                 {
  229.                      int iDrive;   
  230.                      char szDrive[2];
  231.                      BOOTSECTOR *bs;
  232.                      char szBuffer[512];
  233.                      RECT rect; 
  234.                      BOOL bRet;
  235.                      
  236.                      // get the rectangle for the bitmap
  237.                      GetPictRect(hDlg, &rect);
  238.                      InvalidateRect(hDlg, &rect, TRUE);                     
  239.                      
  240.                      // set the focus to the edit control
  241.                      SetFocus(GetDlgItem(hDlg, IDC_DRIVE));                     
  242.                      // hilite the text in the edit control                     
  243.                      SendDlgItemMessage(hDlg, IDC_DRIVE, EM_SETSEL,0,MAKELPARAM(0,-1)); 
  244.                      
  245.                      GetDlgItemText(hDlg, IDC_DRIVE, szDrive, 2);
  246.                      iDrive = szDrive[0] - 'A';
  247.                         
  248.                      if (IsCDRomDrive(iDrive))
  249.                      {                  
  250.                         LoadString(hInst, IDS_NOCDROM, szErrorBuf, sizeof(szErrorBuf));
  251.                         iDriveType = BM_CDROM;        
  252.                         // if the MessageBox has no caption, Windows
  253.                         // will put "Error" as the caption, so we can
  254.                         // save some space by leaving it off...
  255.                         MessageBox(hDlg, szErrorBuf, "", MB_ICONSTOP|MB_OK);                        
  256.                         SetAllLabels(hDlg, "N/A");                                                   
  257.                         UpdateWindow(hDlg);
  258.                         break;
  259.                      }
  260.                      if (IsNetDrive(iDrive))
  261.                      {
  262.                         LoadString(hInst, IDS_NONET, szErrorBuf, sizeof(szErrorBuf));                            
  263.                         iDriveType = BM_NET;
  264.                         MessageBox(hDlg, szErrorBuf, "", MB_ICONSTOP|MB_OK);                        
  265.                         SetAllLabels(hDlg, "N/A");
  266.                         UpdateWindow(hDlg);
  267.                         break;
  268.                      }  
  269.                     
  270.                      
  271.                      SetCapture(hDlg); 
  272.                      SetCursor(LoadCursor(NULL, IDC_WAIT));
  273.                      bRet = ReadBootSector(iDrive, szBuffer);
  274.                      ReleaseCapture();
  275.                      SetCursor(LoadCursor(NULL, IDC_ARROW)); 
  276.                      if (bRet)
  277.                      {    
  278.                          int nDriveType;
  279.                          bs = (BOOTSECTOR *)szBuffer;                     
  280.                          ShowDriveInfo(hDlg, bs);                  
  281.                          nDriveType = MyGetDriveType(bs);
  282.                          switch (nDriveType)
  283.                          {
  284.                             case DRIVE_REMOVABLE:
  285.                                 iDriveType = BM_FLOPPY;
  286.                                 break;
  287.                             case DRIVE_RAM:
  288.                                 iDriveType = BM_RAM;
  289.                                 break;
  290.                             case DRIVE_FIXED:
  291.                                 iDriveType = BM_FIXED; 
  292.                                 break;
  293.                             default: // this should never happen!!
  294.                                 iDriveType = BM_NONE;
  295.                                 break;                                
  296.                           }                        
  297.                      }                               
  298.                      else // failed to read boot sector!
  299.                      {     
  300.                         
  301.                         LoadString(hInst, IDS_READERROR, szErrorBuf, sizeof(szErrorBuf));                            
  302.                         iDriveType = BM_NONE;
  303.                         MessageBox(hDlg, szErrorBuf, "", MB_ICONSTOP|MB_OK);                                                        
  304.                         SetAllLabels(hDlg, "N/A");                     
  305.                         UpdateWindow(hDlg);
  306.                          
  307.                      }
  308.                      
  309.                                          
  310.                 }
  311.                  break;
  312.                 case IDCANCEL:            
  313.                   DestroyWindow(hDlg);                  
  314.                   break;
  315.                 default:              
  316.                     return FALSE; // didn't handle it      
  317.                     break; 
  318.             }                   
  319.         break;        
  320.         case WM_DESTROY:
  321.             SelectObject(hMemDC, hbmOld);
  322.             DeleteObject(hBitmap);
  323.             DeleteDC(hMemDC);
  324.             PostQuitMessage(0);
  325.             break;        
  326.         default:                                     
  327.             return FALSE; //didn't handle the message
  328.             break;        
  329.     }  
  330.  
  331.     return TRUE; // we handled the message
  332.  
  333. }                                                                            
  334.  
  335. /****************************************************************************
  336.  
  337.     FUNCTION: ReadBootSector(int iDrive, PSTR pTemp)
  338.  
  339.     PURPOSE: reads the boot sector of iDrive into the pTemp buffer.
  340.     
  341.     pTemp should be at least 512 bytes 
  342.     
  343.     we use the #pragma to turn optimization off so that the compiler won't
  344.     complain about the inline assembly
  345.     
  346.  
  347. ****************************************************************************/
  348. #pragma optimize("",off)
  349. BOOL ReadBootSector(int iDrive, PSTR pTemp)
  350. {
  351.   
  352.     DISKIO dio;          
  353.     NPDISKIO npDIO;    
  354.     dio.diStartSector = 0;
  355.     dio.diSectors = 1;
  356.     dio.diBuffer = pTemp;
  357.     npDIO = &dio;
  358.   
  359.   _asm 
  360.    {
  361.         mov ax, iDrive    /* Drive number (0 based) */
  362.         mov bx, npDIO     /* Establish buffer for read */        
  363.         mov cx, 0FFFFh    /* use the DISKIO structure */
  364.         xor dx, dx        /* ignored */
  365.         int 25h           /* Absolute Disk Read */        
  366.         jc error
  367.         popf        // pop registers
  368.     }     
  369.       return TRUE;  
  370. error:
  371.     
  372.     return FALSE;
  373. }                
  374. #pragma optimize("",on)
  375.         
  376. /****************************************************************************
  377.  
  378.     FUNCTION: ShowDriveInfo(HWND hDlg, BOOTSECTOR *bs)
  379.  
  380.     PURPOSE: 
  381.              given a pointer to a BOOTSECTOR structure, display its
  382.              contents in the dialog.  Its assumed that the id's of the
  383.              static controls start at ID_FIRST and are sequential to 
  384.              ID_LAST, and are in the same order as the structure.
  385.  
  386. ****************************************************************************/
  387.         
  388. void ShowDriveInfo(HWND hDlg, BOOTSECTOR *bs)
  389. {
  390.     int iParameter,nCount;    
  391.     char szBuf[64];          
  392.     iParameter = ID_FIRST;    
  393.     wsprintf((LPSTR)szBuf, "%#x",(WORD)bs -> bsJump);                           
  394.     SetDlgItemText(hDlg,iParameter++,szBuf);                                      
  395.     wsprintf((LPSTR)szBuf, "%s",(LPSTR)bs -> bsOemName);                           
  396.     SetDlgItemText(hDlg,iParameter++,szBuf);            
  397.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsBytePerSec);
  398.     SetDlgItemText(hDlg,iParameter++,szBuf);
  399.     wsprintf((LPSTR)szBuf, "%d",(BYTE)bs -> bsSecPerCluster);
  400.     SetDlgItemText(hDlg,iParameter++,szBuf);
  401.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsResSectores);
  402.     SetDlgItemText(hDlg,iParameter++,szBuf);
  403.     wsprintf((LPSTR)szBuf, "%d",(BYTE)bs -> bsFAT);
  404.     SetDlgItemText(hDlg,iParameter++,szBuf);
  405.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsRootDirEnts);
  406.     SetDlgItemText(hDlg,iParameter++,szBuf);
  407.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsSectors);
  408.     SetDlgItemText(hDlg,iParameter++,szBuf);
  409.     wsprintf((LPSTR)szBuf, "%#x",(BYTE)bs -> bsMedia);
  410.     SetDlgItemText(hDlg,iParameter++,szBuf);
  411.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsFATsecs);
  412.     SetDlgItemText(hDlg,iParameter++,szBuf);
  413.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsSecPerTrack);
  414.     SetDlgItemText(hDlg,iParameter++,szBuf);
  415.     wsprintf((LPSTR)szBuf, "%d",(WORD)bs -> bsHeads);
  416.     SetDlgItemText(hDlg,iParameter++,szBuf);     
  417. // if we have a RAM drive (only one FAT), then
  418. // all the following information is invalid
  419.     if (MyGetDriveType(bs) != DRIVE_RAM)    
  420.     {
  421.         wsprintf((LPSTR)szBuf, "%ld",(DWORD)bs -> bsHiddenSecs);
  422.         SetDlgItemText(hDlg,iParameter++,szBuf);
  423.         wsprintf((LPSTR)szBuf, "%ld",(DWORD)bs -> bsHugeSectoes);
  424.         SetDlgItemText(hDlg,iParameter++,szBuf);
  425.         wsprintf((LPSTR)szBuf, "%#x",(BYTE)bs -> bsDriveNumber);
  426.         SetDlgItemText(hDlg,iParameter++,szBuf);
  427.         wsprintf((LPSTR)szBuf, "%d",(BYTE)bs -> bsReserved);
  428.         SetDlgItemText(hDlg,iParameter++,szBuf);
  429.         wsprintf((LPSTR)szBuf, "%#x",(BYTE)bs -> bsBootSig);
  430.         SetDlgItemText(hDlg,iParameter++,szBuf);
  431.         wsprintf((LPSTR)szBuf, "%lX",(DWORD)bs -> bsVolumeID); // serial number
  432.         SetDlgItemText(hDlg,iParameter++,szBuf);
  433.          
  434.         // there are no NULL terminated strings
  435.         // so put the whole thing in a terminated
  436.         // string
  437.         memset(szBuf, NULL,64); 
  438.         for (nCount=0; nCount < 11; nCount++)
  439.             szBuf[nCount] =  bs -> bsVolumeLabel[nCount];                  
  440.             
  441.         SetDlgItemText(hDlg,iParameter++,szBuf);   
  442.             
  443.         memset(szBuf, NULL,12);
  444.         for (nCount=0; nCount < 8 ; nCount++)
  445.             szBuf[nCount]=bs -> bsFileSysType[nCount];
  446.                 
  447.         SetDlgItemText(hDlg,iParameter++,szBuf);
  448.       }
  449.      else // its a RAMDRIVE
  450.      {        
  451.         while (iParameter < ID_LAST)
  452.             SetDlgItemText(hDlg, iParameter++, "N/A");
  453.      }
  454.    
  455.    
  456. }                         
  457.  
  458.  
  459.  
  460. /****************************************************************************
  461.  
  462.     FUNCTION: 
  463.               IsCDROM(int iDrive)                                                  
  464.  
  465.     PURPOSE:
  466.               Determines if iDrive is a CD-ROM drive
  467.  
  468. ****************************************************************************/
  469.  
  470. #pragma optimize("",off)
  471. BOOL IsCDRomDrive(int iDrive)
  472. {
  473.    BOOL bRet;
  474.    _asm 
  475.    {
  476.         mov     ax,1500h            ; first test for presence of MSCDEX
  477.         xor     bx,bx
  478.         int     2fh
  479.         mov     ax,bx               ; MSCDEX is not there if BX is still zero
  480.         or      ax,ax               ; ...so return FALSE from this function
  481.         jz      no_mscdex
  482.  
  483.         mov     ax, 150bh           ; MSCDEX driver check API
  484.         mov     cx, iDrive          ; ...cx is drive index
  485.         int     2fh                 ; will return AX=0 iff drive is not CDROM
  486.         mov     bRet, ax
  487.    
  488.    } 
  489.   
  490.    return bRet;
  491.   no_mscdex:
  492.     return FALSE;
  493. }                      
  494. #pragma optimize("",on)
  495.  
  496. /****************************************************************************
  497.  
  498.     FUNCTION: GetPictRect(HWND hWnd, LPRECT lpRect) 
  499.  
  500.     PURPOSE: gets the rectangle to display the drive icon
  501.  
  502. ****************************************************************************/
  503. void GetPictRect(HWND hWnd, LPRECT lpRect) 
  504.     
  505.     GetWindowRect(GetDlgItem(hWnd,IDC_DRIVE), lpRect);    
  506.     ScreenToClient(hWnd, (LPPOINT)lpRect);
  507.     ScreenToClient(hWnd, ((LPPOINT)lpRect)+1);    
  508.     lpRect -> left = lpRect -> right + 5;
  509.     lpRect -> right += BM_WIDTH;
  510.  
  511. }
  512. /****************************************************************************
  513.  
  514.     FUNCTION: IsNetDrive(int iDrive)
  515.  
  516.     PURPOSE: Determines if iDrive is a network drive
  517.  
  518. ****************************************************************************/
  519. WORD IsNetDrive(int iDrive)
  520. {
  521.     int err;
  522.     char szDrive[3];
  523.     char szConn[64];    
  524.     int nSize = 64;
  525.     szDrive[0] = (char)(iDrive+'A');
  526.     szDrive[1] = ':';
  527.     szDrive[2] = (char)0;
  528.  
  529.     if (IsCDRomDrive(iDrive)) 
  530.         return 0;
  531.  
  532.     err = WNetGetConnection(szDrive, szConn, &nSize);
  533.  
  534.     if (err == WN_SUCCESS)
  535.         return 1;
  536.  
  537.     if (err == WN_CONNECTION_CLOSED || err == WN_DEVICE_ERROR)
  538.         return 2;
  539.  
  540.     return 0;
  541. }
  542. /****************************************************************************
  543.  
  544.     FUNCTION: SetAllLabels(HWND hDlg, LPSTR szText)
  545.  
  546.     PURPOSE: Sets all labels in hDlg to szText
  547.  
  548. ****************************************************************************/
  549. void SetAllLabels(HWND hDlg, LPSTR szText)
  550. {
  551.     int i;
  552.     for (i=ID_FIRST; i < ID_LAST; i++)    
  553.         SetDlgItemText(hDlg, i, szText);
  554. }
  555.  
  556.                                               
  557. /****************************************************************************
  558.  
  559.     FUNCTION: 
  560.              NewEditProc(HWND hEdit, UINT message, WPARAM wParam , LPARAM lParam)
  561.  
  562.     PURPOSE: 
  563.              The subclassed edit procedure.  Restricts input of theedit control
  564.              to capital letters, the TAB key, and the backspace key.
  565.  
  566. ****************************************************************************/                                              
  567. long FAR PASCAL __export NewEditProc(HWND hEdit, UINT message, WPARAM wParam , LPARAM lParam)
  568. {
  569.     if (message == WM_CHAR)
  570.     {
  571.         // if it is a lower case letter, convert it to 
  572.         // uppercase - NOTE: This is NOT portable!
  573.         if (wParam <= 'z' && wParam >= 'a')
  574.             wParam -= 'a' - 'A';                  
  575.         
  576.         // allow only letters, TAB, or backspance keys
  577.         if ((wParam <= 'Z' && wParam >= 'A') || (wParam == VK_TAB) || (wParam == VK_BACK))
  578.         {
  579.             
  580.             
  581.             CallWindowProc(lpfnOldEditProc, hEdit, message, wParam, lParam);                                                      
  582.             //we never want more than one character in the
  583.             //control, so after we put the char in there,
  584.             // highlight it
  585.             SendMessage(hEdit, EM_SETSEL,0,MAKELPARAM(0,-1));
  586.             return 0;
  587.         } 
  588.         else
  589.         {  
  590.             MessageBeep(0);                                                     
  591.             return 0L;
  592.         }
  593.         
  594.     
  595.     }
  596.     CallWindowProc(lpfnOldEditProc, hEdit, message, wParam, lParam);
  597.  
  598. }
  599.  
  600. /****************************************************************************
  601.  
  602.     FUNCTION: AboutDlgProc(HWND, unsigned, WORD, LONG)
  603.  
  604.     PURPOSE:  Processes messages for "About" dialog box
  605.  
  606.     MESSAGES:
  607.  
  608.     WM_INITDIALOG - initialize dialog box
  609.     WM_COMMAND    - Input received
  610.  
  611. ****************************************************************************/
  612.  
  613. BOOL FAR PASCAL __export AboutDlgProc (HWND hDlg, UINT message,  WPARAM wParam, LPARAM lParam)
  614. {
  615.  
  616.     switch (message)
  617.     {
  618.         case WM_INITDIALOG:
  619.             return (TRUE);
  620.         case WM_COMMAND:
  621.             if (wParam == IDOK)
  622.             {
  623.                 EndDialog(hDlg, TRUE);
  624.                 return (TRUE);
  625.             }
  626.             break;
  627.     }
  628.     return (FALSE);
  629.  
  630. }
  631. /****************************************************************************
  632.  
  633.     FUNCTION: MyGetDriveType(BOOTSECTOR *bs)
  634.  
  635.     PURPOSE:  Given a pointer to a bootsector, determine what kind of drive
  636.               it is.
  637.               
  638.               Drive         Test
  639.               -----         ----
  640.               RAM           TRUE if only 1 FAT
  641.               FIXED         TRUE if media descriptor is 0xF8h
  642.               FLOPPY        Default 
  643.  
  644.     
  645.     call IsCDRom() and IsNetDrive() before calling this function!
  646.     (or integrate them into it...)
  647.  
  648. ****************************************************************************/
  649. int MyGetDriveType(BOOTSECTOR *bs)
  650. {
  651.     
  652.     
  653.     if (bs -> bsFAT == 1)
  654.         return  DRIVE_RAM;
  655.     if (bs -> bsMedia == 0xF8)
  656.         return DRIVE_FIXED;
  657.         
  658.     return DRIVE_REMOVABLE; 
  659.  
  660. }
  661.